
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>申请报修页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <script type="text/javascript" src="lib/layui/layui.js"
            charset="utf-8"></script>
    <script type="text/javascript" src="js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" enctype="multipart/form-data" id="form">
            <!-- 状态 -->
            <input type="hidden" id="status" name="status" value="0">
            <!--处理人-->
            <input type="hidden" id="bao_xiu_man_id" name="bao_xiu_man_id" value="1">
            <!--处理结果-->
            <input type="hidden" id="repair_res" name="repair_res" value="">
            <!--维修金额-->
            <input type="hidden" id="fee" name="fee" value="">
            <!--设备编号-->
            <div class="layui-form-item">
                <label for="equipment_id" class="layui-form-label"> <span class="x-red"></span>设备编号 </label>
                <div class="layui-input-inline">
                    <input type="text" id="equipment_id" name="equipment_id" value="0"
                           lay-verify="landMark" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <!--故障说明-->
            <div class="layui-form-item">
                <label for="guzhang" class="layui-form-label"> <span class="x-red"></span>故障说明 </label>
                <div class="layui-input-inline">
                    <input type="text" id="guzhang" name="guzhang"
                           lay-verify="landMark" autocomplete="off" class="layui-input">
                </div>
            </div>
            <!--  指定维修工程师-->
            <div class="layui-form-item">
                <label for="repair_man_id" class="layui-form-label">
                    <span class="x-red">*</span>指定维修工程师</label>
                <div class="layui-input-inline">
                    <input type="hidden" id="repair_man_id" name="repair_man_id" readonly lay-verify="repair_man_id"
                           autocomplete="off"
                           class="layui-input">
                    <button class="layui-btn layui-btn-sm" type="button" id="selectRepair" lay-event="selectRepair">
                        选择工程师
                    </button><span id="sname"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"></label> <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="edit" lay-submit="">申报维修</button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer', 'jquery'],
    function () {
        $ = layui.jquery;
        var form = layui.form;
        var str = window.location.search;
        //拿到设备编号
        var equipment_id = str.substring(1);
        //初始化设备编号信息
        $("#equipment_id").val(equipment_id);
        var xiuman_id = window.sessionStorage.getItem("id");
        $("#bao_xiu_man_id").val(repair_man_id);

        //选择工程师   弹框
        $("#selectRepair").click(function (data) {
            layer.open({
                type: 2,
                title: "选择工程师",
                shadeClose: true,
                shade: 0.4,
                area: ['90%', '90%'],
                content: "repair-list.html",
                btn: ['确定', '关闭'],
                yes: function (index) {
                    //当点击‘确定’按钮的时候，获取弹出层返回的值
                    var res = window["layui-layer-iframe" + index].callbackdata();
                    //打印返回的值，看是否有我们想返回的值。
                    console.log(JSON.stringify(res));
                    $("#repair_man_id").val(res.id);
                    $("#sname").text(res.name);
                    //最后关闭弹出层
                    layer.close(index);
                },
                cancel: function () {
                    //右上角关闭回调
                }
            });
            return false;
        });

        //监听提交
        form.on('submit(edit)', function (data) {
            var formdata = new FormData($("#form")[0]);
            console.log(data.field);
            //data.field  拿到表单除文件以外所有的信息
            $.get("dorepair", data.field, function (d) {
                console.log(d);
                if (d.code == 0) {
                    alert(d.msg);
                    xadmin.close();
                    return;
                }
                layer.alert(d.msg);
            })
            return false;
        });
    });
</script>

</body>

</html>